import Fly from "flyio/dist/npm/wx"
import domains from "../config/domains.js"

const { prodBaseUrl, devBaseUrl } = domains
const request = new Fly()

// request实列配置
request.config.baseURL = process.env.NODE_ENV === "development" ? prodBaseUrl : devBaseUrl,

// 请求超时
request.interceptors.response.use(
	(response) => {
		return response
	},
	(err) => {
		uni.showToast({
			title: "请求超时, 请稍后再试...",
			icon: "none"
		})
		return Promise.reject(err)
	}
)

export default request